<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Admin\Eat;
use Input;

class EatController extends Controller
{
    public function index() {

    	$data = Eat::all();
    	
    	return view('admin.eat.index',compact('data'));
    }

    public function add() {
    	if (Input::method() == 'POST') {
    		$data = Input::except('_token');  	
    		$data['scenic_id'] = rand(1,99);
    		$data['eat_time'] = date('Y-m-d H:i:s');
    		$result =Eat::insert($data);
    		return $result ? '1':'0';
    	}else{
    
    	return view('admin.eat.add');
        }
    }
}
